home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 414_02 / portable / wclrtoeo.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-17  |  2.0 KB  |  91 lines

  1. #define    CURSES_LIBRARY    1
  2. #include <curses.h>
  3. #undef    wclrtoeol
  4.  
  5. #ifdef PDCDEBUG
  6. char *rcsid_wclrtoeo = "$Header: C:\CURSES\portable\RCS\wclrtoeo.c 2.1 1993/06/18 20:21:36 MH Rel MH $";
  7. #endif
  8.  
  9.  
  10.  
  11.  
  12. /*man-start*********************************************************************
  13.  
  14.   wclrtoeol()    - erase line to right of cursor in window
  15.  
  16.   X/Open Description:
  17.      The current line to the right of the cursor, inclusive, is erased.
  18.  
  19.      NOTE: clrtoeol() is a macro.
  20.  
  21.   PDCurses Description:
  22.      In addition to the X/Open specification, there also exist
  23.      mv[w]clrtoeol() versions which first position the cursor
  24.      then perform the [w]clrtoeol call.
  25.  
  26.   X/Open Return Value:
  27.      The wclrtoeol() function returns OK on success and ERR on error.
  28.  
  29.   PDCurses Errors:
  30.      It is an error to call this function with a NULL window pointer.
  31.  
  32.   Portability:
  33.      PDCurses    int wclrtoeol( WINDOW* win );
  34.      X/Open Dec '88    int wclrtoeol( WINDOW* win );
  35.      BSD Curses    int wclrtoeol( WINDOW* win );
  36.      SYS V Curses    int wclrtoeol( WINDOW* win );
  37.  
  38. **man-end**********************************************************************/
  39.  
  40. int    wclrtoeol(WINDOW *win)
  41. {
  42.     int    y;
  43.     int    x;
  44.     int    minx;
  45.     chtype    blank;
  46.     chtype*    maxx;
  47.     chtype*    ptr;
  48.     chtype*    end;
  49.  
  50. #ifdef PDCDEBUG
  51.     if (trace_on) PDC_debug("wclrtoeol() - called\n");
  52. #endif
  53.  
  54.     if (win == (WINDOW *)NULL)
  55.         return( ERR );
  56.  
  57.     y    = win->_cury;
  58.     x    = win->_curx;
  59.     blank    = win->_blank | win->_attrs;
  60.     end    = &win->_y[y][win->_maxx - 1];
  61.     minx    = _NO_CHANGE;
  62.     maxx    = &win->_y[y][x];
  63.  
  64.     for (ptr = maxx; ptr <= end; ptr++)
  65.     {
  66.         if (*ptr != blank)
  67.         {
  68.             maxx = ptr;
  69.             if (minx == _NO_CHANGE)
  70.             {
  71.                 minx = (int) (ptr - win->_y[y]);
  72.             }
  73.             *ptr = blank;
  74.         }
  75.     }
  76.  
  77.     if (minx != _NO_CHANGE)
  78.     {
  79.         if ((win->_firstch[y] > minx) ||
  80.             (win->_firstch[y] == _NO_CHANGE))
  81.         {
  82.             win->_firstch[y] = minx;
  83.         }
  84.         if (win->_lastch[y] < maxx - win->_y[y])
  85.         {
  86.             win->_lastch[y] = (int) (maxx - win->_y[y]);
  87.         }
  88.     }
  89.     return( OK );
  90. }
  91.